package com.yunxun.coinmessage.dao;


import com.yunxun.coinmessage.entity.Program;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component
public interface ProgramDao {
    @Insert("insert into program (program_name) values(#{program_name})")
    Integer add(String program_name);
    //查询所有栏目
    @Select("select * from program where status=1")
    List<Program> queryAll();


    //根据id删除记录
    @Update("update program set status=0 where program_id=#{program_id}")
    Integer deleteById(Integer program_id);

    //查询总记录数
    @Select("select count(*) from program where status=1")
    Integer queryTotal();

    //根据id改栏目名字
    @Update("update program set program_name=#{program_name}  where program_id=#{program_id}" )
    Integer updateById(Program program);

    @Select("select * from program where program_id=#{program_id}")
    public Program queryById(Integer program_id);

    //根据栏目名查询
    @Select("select * from program where program_name=#{program_name} ")
    Program queryByName(String program);

    @Select("select program_name from program where program_id=#{program_id}")
    String queryNameById(@Param("program_id") int program_id);

}
